<template>
	<view style="width: 100%;height: 100%;" :style="{'border-radius': radius}">
		<video v-show="video" :muted="muted" :id="`v_${id}`" webkit-playsinline='true' playsinline='true'
			style="width: 100%;height: 100%;" :style="{'border-radius': radius}" autoplay object-fit="cover"></video>
		<view v-if="!video"
			style="width: 100%;height: 100%;display: flex;flex-direction: column;align-items: center;background: #33333333;color: #e0e5fa;">

			<view style="margin-top: 30%;font-size: 35rpx;">
				<u-avatar size="60" :src="$store.state.common.systemInfo.fileurl + 'avatar/' + uid + '.jpg'"></u-avatar>
			</view>
			<view style="margin-top: 20rpx;font-size: 24rpx;">
				{{name}}
			</view>

			<view style="display: flex;justify-content: center;align-items: center;margin-top: 25rpx;">
				<view v-if="audio"
					style="width: 40rpx;height: 40rpx;display: flex;justify-content: center;align-items: center;border-radius: 60rpx;">
					<image src="/static/images/dfaa.png" style="width: 30rpx;" mode="widthFix"></image>
				</view>
				<view v-if="!audio"
					style="width: 40rpx;height: 40rpx;display: flex;justify-content: center;align-items: center;border-radius: 60rpx;">
					<image src="/static/images/dfab.png" style="width: 30rpx;" mode="widthFix"></image>
				</view>
				<view v-if="!video"
					style="margin-left: 2rpx; width: 40rpx;height: 40rpx;display: flex;justify-content: center;align-items: center;border-radius: 60rpx;">
					<image src="/static/images/dfccamerb.png" style="width: 30rpx;" mode="widthFix"></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {

			}
		},
		props: {
			id: {
				type: String | Number,
				default: ''
			},
			uid: {
				type: String | Number,
				default: ''
			},
			name: {
				type: String | Number,
				default: ''
			},
			radius: {
				type: String | Number,
				default: '0rpx'
			},
			src: {
				type: MediaStream,
			},
			muted: {
				type: Boolean,
				default: false
			},
			status: {
				type: String,
				default: 'play'
			},
			video: {
				type: Boolean,
				default: false
			},
			audio: {
				type: Boolean,
				default: false
			}
		},
		watch: {
			src: function(v) {
				console.log(9999,v,this.id,this.name)
				if (v && v.id) {
					setTimeout(()=>{
						const content = document.getElementById(`v_${this.id}`);
						const items = content.getElementsByTagName("video");
						if (items && items.length > 0) {
							items[0].srcObject = v
						}
					},200)
				}
			}
		},
		mounted() {
			console.log(9999,this.id,this.name,this.src)
			if(this.src && this.src.id){
				setTimeout(()=>{
					const content = document.getElementById(`v_${this.id}`);
					const items = content.getElementsByTagName("video");
					if (items && items.length > 0) {
						console.log(items[0],this.src)
						items[0].srcObject = this.src
					}
				},200)
			}
		}
	}
</script>

<style>
</style>